<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        html {
            perspective: 800px;
        }

        body {
            min-height: 100vh;
            background-color: #abefe9;
        }

        body>div {
            margin: 5px;
            border: #bfa 3px solid;
            background-color: #FFCCCC;
            height: 100px;
            width: 100px;
            transition: 2s;
            margin: 50px auto;
        }

        hr {
            background-color: red;
            height: 1px;
            border: 0;
        }

        .d1:hover {
            transform: translate(50px, 50px);
            /* transform: translateZ(100px); */
            /* 
            translate[X/Y/Z] 沿轴平移
            未旋转时，Z轴指向屏幕外，需要配合HTML设置perspective(视距)，近大远小
             */
            /* 
             transform-style: preserve-3d;
             设置允许3D效果
              */
        }

        .d2:hover {
            transform: translateZ(400px);
        }

        .d3:hover {
            transform: rotateY(360deg) translateZ(400px);
            /* rotate[X/Y/Z]  沿轴旋转*/
            background-color: #027aff;
        }

        .d4:hover {
            transform: translateZ(400px) rotateY(360deg);
            background-color: #027aff;
        }
    </style>
</head>

<body>
    <div class="d1"></div>
    <div class="d2"></div>
    <div class="d3"></div>
    <div class="d4"></div>
</body>

</html>